                            <div class="main">
                                <h3 class="title"><?=$clabel?> &raquo; <?=$mlabel?></h3>
                                <div class="formdiv">
                                    <form method="POST" id="frmAddMenuItem">
                                        <table>
                                            <? if( isset($errors) ) {
                                               foreach($errors as $error) {
                                               ?>
                                            <tr>
                                                <td class="errormsg" colspan="3">
                                                    <?=$error?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <? if( isset($successes) ) {
                                               foreach($successes as $success) {
                                               ?>
                                            <tr>
                                                <td class="successmsg" colspan="3">
                                                    <?=$success?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <tr>
                                                <td><label for="mglabel">Menu Group*</label></td>
                                                <td>
                                                    <select name="mgid" class="text required">
                                						<option value="">---- Select -----</option>
                                						<?
                                							foreach( $menugroups as $menugroup  ) {
                                                                if($postdata['mgid'] == $menugroup["mgid"])
                                									echo "<option value='".$menugroup["mgid"]."' selected='true' >".$menugroup["mglabel"]."</option>";
                                								else
                                								    echo "<option value='".$menugroup["mgid"]."'>".$menugroup["mglabel"]."</option>";
                                							}
                                						?>
                                					</select>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="milabel">Menu Item Label*</label></td>
                                                <td>
                                                    <input type="text" class="text required" maxlength="30" minlength="3" name="milabel" value="<?=$postdata['milabel']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="miurl">Menu Item Url*</label></td>
                                                <td>
                                                    <input type="text" class="text required" maxlength="20" minlength="3" name="miurl" value="<?=$postdata['miurl']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                        	<tr>
                                                <td><label for="miposition">Position*</label></td>
                                                <td>
                                                    <input type="text" class="text required" name="miposition" value="<?=$postdata['miposition']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="miactive">Active*</label></td>
                                                <td>
                                                    <input value="1" class="required" type="radio" <? if($postdata['miactive']=='1') echo "CHECKED=\"true\""; ?> id="miactivetrue" name="miactive"/><label for="miactivetrue">True</label>
                                                    <input value="0" class="required" type="radio" <? if($postdata['miactive']=='0') echo "CHECKED=\"true\""; ?> id="miactivefalse" name="miactive"/><label for="miactivefalse">False</label>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="mihidden">Hidden*</label></td>
                                                <td>
                                                    <input value="1" class="required" type="radio" <? if($postdata['mihidden']=='1') echo "CHECKED=\"true\""; ?> id="mihiddentrue" name="mihidden"/><label for="mihiddentrue">True</label>
                                                    <input value="0" class="required" type="radio" <? if($postdata['mihidden']=='0') echo "CHECKED=\"true\""; ?> id="mihiddenfalse" name="mihidden"/><label for="mihiddenfalse">False</label>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="miroles">User Rights</label></td>
                                                <td>
                                                                                                    
                                                    <?
                                							foreach( $roles as $role  ) {
                                					?>
                                                            <input type="checkbox" id="mirole<?=$role['roleid']?>" <? if(isset($role['roleid']) && isset($postdata['miroles']) && in_array($role['roleid'],$postdata['miroles'])) echo "CHECKED=\"true\""; ?> name="miroles[]" value="<?=$role['roleid']?>" />
                                                            <label for="mirole<?=$role['roleid']?>"><?=$role['roletitle']?></label><br />
                                                    <?           
                                                            }		 
                                                    ?>
                                                </td>
                                                <td></td>
                                            </tr>
                                        	<tr>
                                        		<td></td>
                                        		<td colspan="2">
                                                    <input class="button" type="submit" name="btnAddMenuItem" value="Add" id="btnAddMenuItem" />
                                                    <input class="button" type="reset" value="Cancel" id="btnreset" />
                                                </td>
                                        	</tr>
                                        </table>
                                	</form>
                                    <script language="javascript" type="text/javascript">
                                        if(typeof jQuery == 'undefined') {
                                            alert('Invalid Request');
                                            window.location = "/";
                                        }
                                        $(document).ready( function() {
                                            $("#frmAddMenuItem").validate({
                                                rules: {
                                                    mgposition: {
                                                        number: true
                                                    }        
                                                },
                                                errorPlacement: function(error, element) {
                                                    placeError(error, element);
                                                },
                                                submitHandler: function(form) {
                                                    var cui = $('#contenttabs .ui-tabs-panel:visible'); 
                                               	    var jqxhr = $.post(
                                                        "/menu/addmenuitem", 
                                                        $("#frmAddMenuItem").serialize(), 
                                                        function (data) {
                                                            $(cui).html(data);
                                                        }
                                                    );
                                                    $(cui).html('<div id="loadingdiv"><div class="centerdiv"><strong>Processing</strong><br/><img src="/images/ajaxloader.gif" /></div></div>');
                                                }
                                            });
                                            
                                            $("#frmAddMenuItem input[type='reset']").click( function() {
                                                $('#frmAddMenuItem label.error').remove();
                                            });
                                        });
                                    </script>
                                 </div> 
                            </div>           